<?php $this->load->view('common/header');?>
<body>
<?php $this->load->view('common/user_center');?>
<div class="main_box">
    <?php $this->load->view('common/menu');?>
    <div class="right_box f_r">
    	<div class="title">
        	<span class="f_l">账单分期</span>
        </div>
        <div class="ifrom_list">
            <dl>
            	<dt>账单总金额：</dt>
                <dd>
                	<span class="money">
                    	<?php echo $cur_month_loan_with_loan_three;?>
                    </span>
                </dd>
            </dl>
            <dl>
            	<dt>请选择期限：</dt>
                <dd>
                	<span class="input">
                    	<select id="loanstage">
                        	<option value="3">3期</option>
                        	<option value="6">6期</option>
                        	<option value="9">9期</option>
                        </select>
                    </span>
                </dd>
            </dl>
            <dl>
            	<dt>还款金额：</dt>
                <dd>
                	<span class="data">
                    	<p><?php echo date("Y年m月").$endday."日";?><em class="per_loan_money"><?php echo $per_cur_month_loan_with_loan_three;?>元</em></p>
                    	<p><?php echo date("Y年m月",strtotime("+1 months",time())).$endday."日";?><em class="per_loan_money"><?php echo $per_cur_month_loan_with_loan_three;?>元</em></p>
                    	<p><?php echo date("Y年m月",strtotime("+2 months",time())).$endday."日";?><em class="per_loan_money"><?php echo $per_cur_month_loan_with_loan_three;?>元</em></p>
                    </span>
                </dd>
            </dl>
            <dl>
            	<dt>&nbsp;</dt>
                <dd>
                	<label>
                    	<input name="" type="checkbox" value="" checked>同意<a href="#">《销售贷分期还款协议》</a>
                    </label>
                </dd>
            </dl>
            <dl>
            	<dt>&nbsp;</dt>
                <dd>
                	<a href="javascript:;" class="nav aplication">申请分期</a>
                </dd>
            </dl>
        </div>
    </div>
</div>
<!--]] user -->
<!-- coypright [[-->
<?php $this->load->view('common/footer');?>
<!--]] coypright -->
<script>
    $("#loanstage").change(function(e){
        var obj = $(this);
        var stage_num = obj.val();
        // area_type.val(1).trigger("change");
        $.ajax({
            method: "GET",
            url: baseurl+"index.php/vip/user/get_loan_by_stage",
            data: {stage_num:stage_num},
            dataType:'JSON'
        }).done(function(msg){
            console.log(msg);
            $(".data").html(msg.data)
        })
    });
    $(".aplication").click(function () {
        var stage_num = $("#loanstage").val();
        $.ajax({
            type: "get",
            url: baseurl+"index.php/vip/user/fenqi_loan",
            dataType:'json',
            data: {
                stage_num:stage_num
            },
            success: function(data){
                console.log(data);
                if(data.status == 1){
                    layer.msg(data.info, {
                        time: 1000, //1s后自动关闭
                        shade: 0.1
                    },function () {
                        window.location.href = baseurl+"index.php/vip/user/user_loan_bill";
                    });
                }else{
                    layer.msg(data.info);
                    return false;
                }

            }
        });
    });
</script>
</body>
</html>
